<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="nav-header">
			<view class="nav-bar">
				<view class="nav-left" @click="goBack">
					<view class="back-arrow"></view>
				</view>
				<view class="nav-title">团购优惠</view>
				<view class="nav-right"></view>
			</view>

			<!-- 占位区域（保持和 navigation.vue 一样的高度） -->
			<view class="search-placeholder"></view>
		</view>

		<!-- 内容区域 -->
		<view class="content-view">
			<scroll-view class="content-scroll" scroll-y>
				<view class="detail-card">
					<!-- 主标题 -->
					<view class="main-title">{{ detailData.title || '汽车惠民活动走进群众生活' }}</view>

					<!-- 来源和日期 -->
					<view class="source-row">
						<text class="source-text">{{ detailData.source || '济源某某汽车行业' }}</text>
						<text class="date-text">{{ detailData.date || '2023/3/10 11:09' }}</text>
					</view>

					<!-- 图片 -->
					<view class="image-section">
						<image class="detail-image" :src="detailData.image" mode="aspectFill"></image>
					</view>

					<!-- 描述文本 -->
					<view class="description">
						<text
							class="description-text">{{ detailData.description || '哇噻!薅羊毛的看过来!易车修汽车维修服务中心出优惠团购了!纯手工洗车只要25元一次,还增20元油券,够意思了吧!哇噻!薅羊毛的看过来!易车修汽车维修服务中心出优惠团购了!纯手工洗车只要25元一次,还增20元油券,够意思了吧!' }}</text>
					</view>
				</view>

				<!-- 价格和信息卡片 -->
				<view class="detail-card">
					<!-- 价格信息 -->
					<view class="price-section">
						<view class="price-row">
							<text class="price-label">价格:</text>
							<text class="current-price">¥{{ detailData.price || '99.00' }}</text>
							<text class="original-price">原价:¥{{ detailData.originalPrice || '199.00' }}</text>
						</view>
					</view>

					<!-- 活动日期 -->
					<view class="info-row">
						<text class="info-label">活动起止日期:</text>
						<text class="info-value">{{ detailData.startDate || '2023-3-10 08:00' }} 至
							{{ detailData.endDate || '2023-3-18 23:59' }}</text>
					</view>

					<!-- 咨询电话 -->
					<view class="info-row">
						<text class="info-label">咨询电话:</text>
						<text class="info-value">{{ detailData.phone || '0379-66666666' }}</text>
					</view>

					<!-- 注意事项 -->
					<view class="info-row">
						<text class="info-label">注意事项:</text>
						<text class="info-value">{{ detailData.notes || '暂无' }}</text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';

	// 详情数据
	const detailData = ref({});

	// 返回
	const goBack = () => {
		uni.navigateBack();
	};

	onLoad((options) => {
		// 接收传递过来的数据
		if (options.data) {
			try {
				const data = JSON.parse(decodeURIComponent(options.data));
				detailData.value = data;
			} catch (e) {
				console.error('解析数据失败', e);
			}
		}
	});
</script>

<style scoped>
	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: #f5f5f5;
		overflow: hidden;
	}

	/* 顶部导航栏 */
	.nav-header {
		background: linear-gradient(180deg, #2477F4 0%, #166BEC 100%);
		padding-top: 30rpx;
		padding-bottom: 30rpx;
	}

	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		padding-top: calc(20rpx + env(safe-area-inset-top));
		position: relative;
	}

	.nav-left {
		width: 80rpx;
		display: flex;
		align-items: center;
		cursor: pointer;
	}

	.back-arrow {
		width: 24rpx;
		height: 24rpx;
		border-left: 4rpx solid #fff;
		border-bottom: 4rpx solid #fff;
		transform: rotate(45deg);
		margin-left: 10rpx;
	}

	.nav-title {
		flex: 1;
		text-align: center;
		font-size: 36rpx;
		font-weight: 500;
		color: #fff;
		position: absolute;
		left: 0;
		right: 0;
		pointer-events: none;
	}

	.nav-right {
		width: 80rpx;
	}

	.icon-circle {
		width: 56rpx;
		height: 56rpx;
		border-radius: 50%;
		background: rgba(255, 255, 255, 0.25);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.three-dots {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 4rpx;
	}

	.dot {
		width: 5rpx;
		height: 5rpx;
		background: #fff;
		border-radius: 50%;
	}

	.target-icon {
		position: relative;
		width: 28rpx;
		height: 28rpx;
	}

	.outer-circle {
		position: absolute;
		top: 0;
		left: 0;
		width: 28rpx;
		height: 28rpx;
		border: 2rpx solid #fff;
		border-radius: 50%;
	}

	.inner-circle {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 10rpx;
		height: 10rpx;
		background: #fff;
		border-radius: 50%;
	}

	/* 搜索栏占位（保持和 navigation.vue 一样的高度） */
	.search-placeholder {
		height: 250rpx;
	}

	/* 内容视图 */
	.content-view {
		flex: 1;
		padding: 0 30rpx 20rpx 30rpx;
		margin-top: -250rpx;
		height: 0;
		overflow: visible;
		display: flex;
		flex-direction: column;
	}

	.content-scroll {
		flex: 1;
		height: 0;
		width: 100%;
	}

	/* 详情卡片 */
	.detail-card {
		width: 100%;
		background: #fff;
		border-radius: 20rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
		padding: 40rpx 30rpx;
		box-sizing: border-box;
		margin-bottom: 20rpx;
	}

	.detail-card:last-child {
		margin-bottom: 0;
	}

	/* 主标题 */
	.main-title {
		font-size: 36rpx;
		font-weight: 500;
		color: #000;
		text-align: center;
		margin-bottom: 20rpx;
		line-height: 1.5;
	}

	/* 来源和日期行 */
	.source-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 30rpx;
	}

	.source-text {
		font-size: 26rpx;
		color: #999;
	}

	.date-text {
		font-size: 26rpx;
		color: #999;
	}

	/* 图片区域 */
	.image-section {
		margin-bottom: 30rpx;
	}

	.detail-image {
		width: 100%;
		height: 400rpx;
		border-radius: 12rpx;
	}

	/* 描述文本 */
	.description {
		margin-bottom: 30rpx;
	}

	.description-text {
		font-size: 28rpx;
		color: #333;
		line-height: 1.8;
		display: block;
	}

	/* 价格区域 */
	.price-section {
		margin-bottom: 30rpx;
		margin-top: 0;
	}

	.price-row {
		display: flex;
		align-items: baseline;
		gap: 20rpx;
	}

	.price-label {
		font-size: 30rpx;
		color: #000;
	}

	.current-price {
		font-size: 44rpx;
		font-weight: bold;
		color: #FF3B30;
	}

	.original-price {
		font-size: 26rpx;
		color: #999;
		text-decoration: line-through;
	}

	/* 信息行 */
	.info-row {
		display: flex;
		margin-bottom: 20rpx;
		line-height: 1.6;
	}

	.info-label {
		font-size: 28rpx;
		color: #000;
		margin-right: 10rpx;
		flex-shrink: 0;
	}

	.info-value {
		font-size: 28rpx;
		color: #333;
		flex: 1;
	}
</style>